package com.socialweb.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

@Entity
@Table(name = "user_data")
@NamedQueries({
    @NamedQuery(name = "UserData.findById",
            query = "SELECT ud FROM UserData ud WHERE ud.Id = :user_id")
//    @NamedQuery(name = "UserData.updateAll",
//            query = "UPDATE UserData ud SET ud.name = :name, ud.surname = :surname,"
//                    + " ud.hobby = :hobby, ud.birth = :birth, ud.email = :email,"
//                    + " ud.phone = :phone WHERE ud.Id = :id")
})
public class UserData implements Serializable{
    
    @Id
    @GeneratedValue
    @Column(name = "user_id")
    private int Id;
    
    @NotBlank
    @Size(min = 2, max = 16)
    @Column(name = "user_name")
    private String name;
    
    @NotBlank
    @Size(min = 2, max = 30)
    @Column(name = "user_surname")
    private String surname;
    
    @Past
    @Column(name = "user_birth")
    @Temporal(javax.persistence.TemporalType.DATE)
    @DateTimeFormat(pattern = "dd.MM.yyyy")
    private Date birth;
    
    @Column(name = "user_hobby")
    private String hobby;
    
    
    @Column(name = "user_phone")
    private String phone;
    
    @Email
    @Column (name = "user_email")
    private String email;

    public String getEmail() {
        return email;
    }

    
    public void setEmail(String email) {
        this.email = email;
    }

    
    public String getPhone() {
        return phone;
    }

    
    public void setPhone(String phone) {
        this.phone = phone;
    }

  
    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    
    public Date getBirth() {
        return birth;
    }
    
    public void setBirth(Date birth) {
        this.birth = birth;
    }

    
    public String getSurname() {
        return surname;
    }

  
    public void setSurname(String surname) {
        this.surname = surname;
    }

    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    
    public int getId() {
        return Id;
    }

    public void setId(int Id) {
        this.Id = Id;
    }
    
}
